package coms.process;

import java.util.Map;
import com.beans.AdminUserBean;
import com.beans.ORGBean;
import com.crc.mam.BaseCase;
import coms.AutoException;
import frame.FrameWork;
import frame.InterTest;
import functions.ems_accountant_job_pool.Group;
import functions.mams_rest.User;

public class AddGroupProcess  extends BaseCase implements InterTest{
  String groupName ;
  ORGBean auditSelectOrg;
  
 

  public String getGroupName() {
    return groupName;
  }

  public void setGroupName(String groupName) {
    this.groupName = groupName;
  }

  public ORGBean getAuditSelectOrg() {
    return auditSelectOrg;
  }

  public void setAuditSelectOrg(ORGBean auditSelectOrg) {
    this.auditSelectOrg = auditSelectOrg;
  }



  /**
   * 入参:companyName,deptName,membersTasks
   * groupType(可不填，默认为0),membersTasks(可不填，默认为100)
   */
  @Override
  public void run(Map<Object, Object> paramMap) {
    String baseUrl = (String) paramMap.get("baseUrl");
    if(baseUrl !=null) {
      FrameWork.setBaseUrl(baseUrl);
    }
      LoginTest loginTest = new LoginTest();
      loginTest.run(paramMap);

      if(!loginTest.status) {
        remark = loginTest.result;
        status = false;
        throw new AutoException("登录失败，阻碍测试");
      }
     Group group = new Group();
     String companyName = (String) paramMap.get("companyName");
     if(companyName == null) {
       User user = new User();
       user.admin();
       AdminUserBean userBean = user.getUserBean();
       companyName = userBean.getCompanyDesc();
     }
     String deptName = (String) paramMap.get("deptName");     
     String  groupType = (String) paramMap.get("groupType");
     if(groupType == null) {
       groupType = "0";
     }
     int type = Integer.valueOf(groupType);
     String delFlg = "0";
     String membersTasks = (String) paramMap.get("membersTasks");
     if(membersTasks == null) {
       membersTasks = "100";
     }
   
     group.save2update(type,delFlg,companyName,deptName,membersTasks);
     if(group.status) {
       groupName = group.getGroupName();
       auditSelectOrg = group.getSelectedOrg();
       status = true;
       remark = "[groupName=" + groupName+"]";
     }else {
       status = false;
       remark = group.getRemark();
     }
    
  }

  @Override
  public boolean getStatus() {
    return status;
  }
  
  

}
